package com.sxjh.controller.cb;

import com.sxjh.common.BaseController;
import com.sxjh.config.Authorization;
import com.sxjh.common.Result;
import com.sxjh.entity.param.Finance4ListParam;
import com.sxjh.entity.result.Finance4KhKpResult;
import com.sxjh.entity.result.Finance4KhMxResult;
import com.sxjh.entity.result.Finance4KhXsResult;
import com.sxjh.entity.result.Finance4ListResult;
import com.sxjh.service.FinanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/tar-sell")
@Api(tags = "焦油加工厂")
public class Finance4Controller extends BaseController {

  @Autowired
  private FinanceService financeService;

  @Authorization("cb.tar-sell.list")
  @GetMapping("/list")
  @ApiOperation("按产品分类的综合报表")
  public Result<List<Finance4ListResult>> list(@Validated Finance4ListParam param) {
    return ok(financeService.list12(param));
  }

  @Authorization("cb.tar-sell.kh-xh")
  @GetMapping("/kh-xh")
  @ApiOperation("客户销售报表")
  public Result<List<Finance4KhMxResult>> khXs(@Validated Finance4ListParam param) {
//    return ok(financeService.list14(param, 0));

    param.setCategoryId(5);
    return ok(financeService.list33(param, 1));
  }

  @Authorization("cb.tar-sell.cp-xh")
  @GetMapping("/cp-xh")
  @ApiOperation("产品销售报表")
  public Result<List<Finance4KhMxResult>> cpXs(@Validated Finance4ListParam param) {
//    return ok(financeService.list15(param, 0));
    param.setCategoryId(5);
    return ok(financeService.list33(param, 5));
  }

  @Authorization("cb.tar-sell.kh-mx")
  @GetMapping("/kh-mx")
  @ApiOperation("客户明细销售报表")
  public Result<List<Finance4KhMxResult>> khMx(@Validated Finance4ListParam param) {
    return ok(financeService.list16(param, 0));
  }

  @Authorization("cb.tar-sell.kh-kp")
  @GetMapping("/kh-kp")
  @ApiOperation("按客户分类的开票报表")
  public Result<List<Finance4KhKpResult>> khKp(@Validated Finance4ListParam param) {
    return ok(financeService.list17(param, 0));
  }

}